﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HeathCareSystem.wuc
{
    public partial class wucThemDonViMoi : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnThem_Click(object sender, EventArgs e)
        {
            DonViThuocDTO dvDTO = new DonViThuocDTO();
            dvDTO.tenDonViThuoc = this.txtMoi.Text;
            if (DonViThuocBUS.ThemDonViThuocMoi(dvDTO))
            {
                lblThongBao.Text = "Them Thuoc Thanh cong!";
            }
            else
            {
                lblThongBao.Text = "Them Thuoc That bai!";
            }
        }

        protected void btnSua_Click(object sender, EventArgs e)
        {
            DonViThuocDTO dvDTO = new DonViThuocDTO();
            dvDTO.tenDonViThuoc = this.txtMoi.Text;
            if (DonViThuocBUS.Update(dvDTO))
            {
                lblThongBao.Text = "Cap Nhat Thuoc Thanh cong!";
            }
            else
            {
                lblThongBao.Text = "Cap Nhat Thuoc That bai!";
            }
        }

        protected void btnXoa_Click(object sender, EventArgs e)
        {
            DonViThuocDTO dvDTO = new DonViThuocDTO();
            dvDTO.tenDonViThuoc = this.txtCu.Text;
            if (ThuocBUS.Delete(dvDTO.maDonViThuoc.ToString()))
            {
                lblThongBao.Text = "Xoa Thuoc Thanh cong!";
            }
            else
            {
                lblThongBao.Text = "Xoa Thuoc That bai!";
            }
        }
    }
}